﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using FanaticRock.Core.DI;
using FanaticRock.ViewModels;

namespace FanaticRock.Views.Tray
{
    /// <summary>
    /// TrayToolWindow.xaml 的交互逻辑
    /// </summary>
    [InjectMe]
    public partial class TrayToolWindow : Window
    {
        private MainViewModel _dataContext;
        public TrayToolWindow(MainViewModel dataContext)
        {
            InitializeComponent();
            DataContext = dataContext;
            AddHandler(ButtonBase.ClickEvent, new RoutedEventHandler(OnButtonClicked));
            AddHandler(FrameworkElement.MouseMoveEvent, new MouseEventHandler(OnPreviewMouseMove));
        }

        private void OnPreviewMouseMove(object sender, MouseEventArgs e)
        {
            if (e.LeftButton != MouseButtonState.Pressed) return;
            DragMove();
        }

        private void OnButtonClicked(object sender, RoutedEventArgs e)
        {
            if (e.OriginalSource is ButtonBase button)
            {
                var tag = button.Tag as string;
                if (string.IsNullOrWhiteSpace(tag)) return;
                if (string.Equals(tag, "fold_music_panel"))
                {
                    //SetMusicPanelExpand(false);
                }
                else if (string.Equals(tag, "expand_music_panel"))
                {
                    //SetMusicPanelExpand(true);
                }
                else if (string.Equals(tag, "close_right_dock_play_list_view"))
                {
                    //SetRightDockPlayListExpand(false);
                }
                else if (string.Equals(tag, "open_right_dock_play_list_view"))
                {
                    //SetRightDockPlayListExpand(true);
                }
                else if (string.Equals(tag, "close_window"))
                {
                    //CloseWindow();
                }
            }
        }
    }
}
